package br.unesp.demac.ccn07.aula5.gui;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.SystemColor;
import java.awt.event.*;

import javax.swing.*;

public class Exemplo4GUI extends JFrame{
	private JButton btAbrir, btSalvar, btFechar;
	private JTextArea taEditor;
	
	public Exemplo4GUI() {
		super("Exemplo 4");
		setSize(300, 200);
		setBackground(SystemColor.control);
		
		// North
		JPanel p1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
		
		for (int i = 0; i < 3; i++) {
			p1.add(new JLabel(new ImageIcon(
					getClass().getResource("images/yellow.jpg"))));
			p1.add(new JLabel(new ImageIcon(
					getClass().getResource("images/grey.jpg"))));
		}
		
		getContentPane().add(p1, "North");
		
		
		
		// East
		p1 = new JPanel();
		JPanel p2 = new JPanel(new GridLayout(3, 1, 5, 5));
		p2.add(btAbrir = new JButton("Abrir"));
		p2.add(btSalvar = new JButton("Salvar"));
		p2.add(btFechar = new JButton("Fechar"));
		p1.add(p2);
		getContentPane().add(p1, "East");
		
		
		
		// Center
		getContentPane().add(new JScrollPane(
				taEditor = new JTextArea()), "Center");
		
		btFechar.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent event){
				btFecharClick();
			}
		});
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setVisible(true);
	}
	
	private void btFecharClick() {
		System.exit(0);
	}
	
	public static void main(String args[]) {
		Exemplo4GUI ex = new Exemplo4GUI();
	}

}
